import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: '',
            coin: 0,
            headImg: require('@/assets/img/userImg.f8bbec5e.png')
        },
        cartTotal: 0
    },
    mutations: {
        changUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: '',
                coin: 0,
                headImg: require('@/assets/img/userImg.f8bbec5e.png')
            }
            state.cartTotal = 0
        }
    },
    actions: {
        async asyncChangUserInfo(context) {
            let user = await UserProfilesAPI();
            context.commit("changUserInfo", user.data)
        }
    }
}